import {
	showToast
} from '@/utils/uniApi.js'

const request = ({
	path = '',
	data = {},
	method = 'GET'
}) => {
	const token = uni.getStorageSync("_TOKEN") 
	return new Promise((resolve, reject) => {
		uni.request({
			url: 'https://hys.jiuhuizhan.com/api/' + path,
			method,
			data,
			header: {
				token
			},
			success: res => {
				const {
					data: resData
				} = res
				const {
					data,
					code,
					message
				} = resData
				
				if (code === 1) {
					resolve(data)
				} else {
					if (message) {
						showToast({
							title: message
						})
					}
					reject(resData)
				}

			},
			fail: (res) => {
				reject(res)
			},

		});
	})
}
export default request;
export const BASE_OSS_URL = "https://apihys.好应首.中国";